#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1005;

ll n, h, r;
struct Node {
  ll x, y, z;
} a[N];
int f[N];
void init(int n) { rep(i, 1, n) f[i] = i; }
int find(int x) { return f[x] == x ? x : find(f[x]); }
void merge(int x, int y) {
  int fx = find(x), fy = find(y);
  if (fx != fy) f[fy] = fx;
}
bool is_connect(int i, int j) {
  ll dx = a[i].x - a[j].x;
  ll dy = a[i].y - a[j].y;
  ll dz = a[i].z - a[j].z;
  return dx * dx + dy * dy <= 4 * r * r - dz * dz;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> h >> r;
    rep(i, 1, n) cin >> a[i].x >> a[i].y >> a[i].z;
    init(n + 2);
    rep(i, 1, n) {
      if (a[i].z <= r) merge(n + 1, i);
      if (a[i].z + r >= h) merge(n + 2, i);
    }
    rep(i, 1, n) {
      rep(j, i + 1, n) {
        if (is_connect(i, j)) merge(i, j);
      }
    }
    if (find(n + 1) == find(n + 2))
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}